import { bestMw, fmtMw, placeLine } from "@/lib/format"; import { STATUS_LABEL, TYPE_LABEL } from "@/lib/labels"; import { OG_CONTENT_TYPE, OG_SIZE, renderOg } from "@/lib/og-template"; import { getFacility, mwIsEstimate } from "./data"; export const alt = "Data center profile on DataCenterIndex"; export const size = OG_SIZE; export const contentType = OG_CONTENT_TYPE; export const revalidate = 3600; export default async function Image({ params }: { params: Promise<{ slug: string }> }) { const { slug } = await params; const r = await getFacility(slug); if (!r.ok) return renderOg({ eyebrow: "Data center", title: "DataCenterIndex", subtitle: "The global index of data center infrastructure." }); const f = r.data; const { mw, kind } = bestMw(f); const mwLabel = kind === "it" ? "IT capacity" : kind === "total" ? "Total power" : kind === "planned" ? "Planned power" : "Capacity"; return renderOg({ eyebrow: "Data center", title: f.name, subtitle: [f.operator?.name, placeLine(f)].filter((s) => s && s !== "—").join(" · "), stats: [ { label: mwLabel, value: mw === null ? "—" : `${mwIsEstimate(f) || kind === "planned" ? "≈ " : ""}${fmtMw(mw)}` }, { label: "Status", value: STATUS_LABEL[f.status] }, { label: "Type", value: TYPE_LABEL[f.facilityType] }, { label: "Country", value: f.countryName ?? f.countryIso2 ?? "—" }, ], }); }